function [ reward,died ] = getStateReward( state,paramIncrementalLoss,paramDeathPenalty)
%GETSTATEACTIONREWARD Summary of this function goes here
%   Detailed explanation goes here
global paramStateRows;
global paramStateCols;
global paramIncrementalLoss;
global paramDeathPenalty
reward = zeros(size(state,2),1);
died = zeros(size(state,2),1);
for i=1:size(reward,1)
    [ board, ~ ] = qStateToGameState( state(:,i) );
    for j=1:size(board,2)
        rowReward = paramIncrementalLoss*find(board(:,j)>0,1,'first');
        if isempty(rowReward)
            rowReward = 0;
        end
        if rowReward == paramStateCols*paramIncrementalLoss
            reward(i) = reward(i) + paramDeathPenalty;
            died(i) = 1;
        else
            reward(i) = reward(i) + rowReward;
        end        
    end    
end

